package com.zhentao.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhentao.pojo.TSheng;
import com.zhentao.pojo.TShi;
import com.zhentao.service.TShengService;
import com.zhentao.service.TShiService;
import com.zhentao.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private TShengService tShengService;
    @Autowired
    private TShiService tShiService;
    @RequestMapping("sheng")
    public Result sheng(){
        List<TSheng> list=tShengService.list();
        return list!=null?Result.OK(list):Result.ERROR();
    }
    @RequestMapping("/shi")
    public Result shi(Integer sid){
        QueryWrapper<TShi> shiQueryWrapper=new QueryWrapper<>();
        shiQueryWrapper.eq("sheng_id",sid);
        List<TShi> list=tShiService.list(shiQueryWrapper);
        return list!=null?Result.OK(list):Result.ERROR();
    }
}
